<div class="row-fluid">
	<div class="span12">
		<ul class="breadcrumb">
			<li>
				<a href="index.php">
					<i class="radmin-icon radmin-home"></i>
					<?php echo t('page', 'Dashboard'); ?>
				</a>
				<span class="divider">/</span>
			</li>
			<li class="active">
				<i class="radmin-icon radmin-cabinet"></i>
				<?php echo t('page', 'Backups'); ?>
			</li>
		</ul>
	</div>
</div>

<div class="row-fluid">
	<div class="span12">
		<h4 class="title"><?php $this->widget('application.components.mywidgets.WikiHelp', array('wiki' => 'backups')); ?> <?php echo t('page', 'Backups'); ?></h4>
		<div class="squiggly-border"></div>
		<ul class="nav nav-tabs" id="backupTab">
			<li class="active"><a href="#account"><?php echo t('page', 'By Account'); ?></a></li>
			<li><a href="#group"><?php echo t('page', 'By Group'); ?></a></li>
			<li><a href="#host"><?php echo t('page', 'By Host'); ?></a></li>
		</ul>
		<div class="tab-content">
			<div class="tab-pane active" id="account">
				<?php echo CHtml::dropDownList('id_account', '', $backupForm->listAccounts(), array('class' => 'search_cpanel')); ?>
			</div>
			
			<div class="tab-pane" id="group">
				<?php echo CHtml::dropDownList('id_group', '', $backupForm->listGroups(), array('class' => 'search_cpanel')); ?>
			</div>
			
			<div class="tab-pane" id="host">
				<?php echo CHtml::dropDownList('id_host', '', $backupForm->listHosts(), array('class' => 'search_cpanel')); ?>
			</div>
		</div>
		<?php $this->renderPartial('forms/_backup', array('backupForm' => $backupForm)); ?>
		
		<script>
			$('#backupTab a').click(function(e){
				e.preventDefault();
				$(this).tab('show');
			});
			$(function () {
				$('.search_cpanel').change(function(){
					var obj = $(this);
					var type = $(this).attr('id');
					var CpanelAccountsSearchForm = {};
					CpanelAccountsSearchForm[type] = $(this).val();
					$.ajax({
						url: <?php echo json_encode(url('whm/cpanelaccount/searchresult')); ?>,
						type: 'post',
						data: {
							'CpanelAccountsSearchForm': CpanelAccountsSearchForm
						},
						success: function(cpanelAccounts){
							$('#id_cpanel_accounts').html('');
							$.each(cpanelAccounts, function(id_cpanel_accounts, domain){
								$('#id_cpanel_accounts').append(
									$('<option />').attr('value', id_cpanel_accounts).text(domain)
								);
							});
							$('#id_cpanel_accounts').change().trigger('liszt:updated');
						},
						dataType: 'json'
					});
				});
				
				$('#backupTab a[href="#group"]').tab('show');
				$('#group .search_cpanel').change();
				$('#backupTab a').click(function(){
					$($(this).attr('href') + ' .search_cpanel').change();
				});

			});
		</script>
	</div>
</div>